home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / gfx / fract / FlashMandel.lha / Sources / Modules / Julia.S < prev    next >
Text File  |  2000-09-17  |  7KB  |  102 lines

  1. ***********************************************************************************************
  2. **            Written by Dino Papararo            08-Sep-2000                                 *
  3. **                                                                                            *
  4. **  FUNCTION                                                                                  *
  5. **                                                                                            *
  6. **    Julia -- perform Z = Z^2 + C iteration.                                                 *
  7. **                                                                                            *
  8. **  SYNOPSIS                                                                                  *
  9. **                                                                                            *
  10. **    WORD Julia68k_FPU (WORD Iterations,long double Cre,long double Cim)                     *
  11. **                                                                                            *
  12. **                                                                                            *
  13. **  DESCRIPTION                                                                               *
  14. **                                                                                            *
  15. **  C equivalent function:                                                                    *
  16. **                                                                                            *
  17. **      ***************************************************************************************
  18. **      *WORD Julia (WORD Iterazioni,double Cre,double Cim,const double Jim,cont double Jre)***
  19. **      *{                                                                                  ***
  20. **      *register long double zr,zi,zi2,dist,maxdist;                                       ***
  21. **      *                                                                                   ***
  22. **      *  zi = Cim;                                                                        ***
  23. **      *                                                                                   ***
  24. **      *  zr = Cre;                                                                        ***
  25. **      *                                                                                   ***
  26. **      *  maxdist = 4;                                                                     ***
  27. **      *                                                                                   ***
  28. **      *  do {                                                                             ***
  29. **      *       zi2 = zi;                                                                   ***
  30. **      *                                                                                   ***
  31. **      *       zi  *= zr;                                                                  ***
  32. **      *                                                                                   ***
  33. **      *       zr  *= zr;                                                                  ***
  34. **      *                                                                                   ***
  35. **      *       zi2 *= zi2;                                                                 ***
  36. **      *                                                                                   ***
  37. **      *       dist = zr;                                                                  ***
  38. **      *                                                                                   ***
  39. **      *       dist += zi2;                                                                ***
  40. **      *                                                                                   ***
  41. **      *       if (dist > maxdist) return Iterazioni;                                      ***
  42. **      *                                                                                   ***
  43. **      *       zi += zi;                                                                   ***
  44. **      *                                                                                   ***
  45. **      *       zr -= zi2;                                                                  ***
  46. **      *                                                                                   ***
  47. **      *       zi += Jim;                                                                  ***
  48. **      *                                                                                   ***
  49. **      *       zr += Jre;                                                                  ***
  50. **      *                                                                                   ***
  51. **      *     } while (-- Iterazioni);                                                      ***
  52. **      *                                                                                   ***
  53. **      *  return 0;                                                                        ***
  54. **      *}                                                                                  ***
  55. **      ***************************************************************************************
  56. **                                                                                            *
  57. **  This function tests if a point belongs or not at Julia set                                *
  58. **                                                                                            *
  59. **  Optimized for pipelines of 68882+ coprocessors                                            *
  60. **                                                                                            *
  61. **  NOTICE: ALL VARIABLES ARE INTO REGISTERS FOR FULL SPEEEED                                 *
  62. **                                                                                            *
  63. **  d0:Iterations                                                                             *
  64. **                                                                                            *
  65. **  fp0:Cre/Jre fp1:Cim/Jim fp2:Zr fp3:Zi fp4:Zi2 fp5:Dist fp6:Tmp/MaxDist fp7:Tmp            *
  66. ***********************************************************************************************
  67.  
  68. *        MACHINE  68060
  69.  
  70.         XDEF  _Julia68k_FPU
  71.  
  72. _Julia68k_FPU:
  73.         
  74.         fmove.x fp0,fp2  * Zr = Cre
  75.         fmove.x fp1,fp3  * Zi = Cim
  76.         fmove.x fp6,fp0  * Moving Julia real constant to fp0
  77.         fmove.x fp7,fp1  * Moving Julia imag constant to fp1
  78.         fmove.x #4,fp6   * MaxDist = 4
  79. Loop:
  80.  
  81.         fmove.x fp3,fp4  * zi2  =  zi
  82.         fmul.x  fp2,fp3  * zi   =  zr * zi
  83.         fmul.x  fp2,fp2  * zr   =  zr * zr
  84.         fmul.x  fp4,fp4  * zi2 *=  zi
  85.         fmove.x fp2,fp5  * dist =  zr
  86.         fadd.x  fp4,fp5  * dist += zi2
  87.         fcmp.x  fp6,fp5  * cmp  MaxDist  dist
  88.         fbgt.w  Exit     * if   dist > MaxDist  exit
  89.         fadd.x  fp3,fp3  * zi   += zi
  90.         fsub.x  fp4,fp2  * zr   -= zi2
  91.         fadd.x  fp1,fp3  * zi   += Jim
  92.         fadd.x  fp0,fp2  * zr   += Jre
  93.  
  94.         dbra.w  d0,Loop  * if --Iterations go to Loop
  95.         moveq.l #0,d0    * Iterations = 0
  96.  
  97. Exit:
  98.  
  99.         rts  * return Iterations
  100.  
  101.         end
  102.